package com.cjhhv.visual.service.impl;

import com.cjhhv.visual.dao.DashboardCategoryDao;
import com.cjhhv.visual.model.DashboardCategoryModel;
import com.cjhhv.visual.service.DashboardCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

@Service
@Transactional( rollbackFor = Exception.class)
public class DashboardCategoryServiceImpl  implements DashboardCategoryService {

    private DashboardCategoryDao dashboardCategoryDao;

    public int queryDashboardCategoryIsExist(DashboardCategoryModel dashboardCategoryModel){
        return  this.dashboardCategoryDao.queryDashboardCategoryIsExist(dashboardCategoryModel);
    }
    public DashboardCategoryModel queryDashboardCategoryById(String dashboardCategoryId){
        return this.dashboardCategoryDao.queryDashboardCategoryById(dashboardCategoryId);
    }

    public  DashboardCategoryModel saveDashboardCategory(DashboardCategoryModel dashboardCategoryModel){
        dashboardCategoryModel.setDashboardCategoryId(UUID.randomUUID().toString());
         int result = this.dashboardCategoryDao.saveDashboardCategory(dashboardCategoryModel);
         if(result>0){
             return dashboardCategoryModel;
         }
         return null;
    }

    public List<DashboardCategoryModel> queryDashboardCategoryList(DashboardCategoryModel dashboardCategoryModel){
        return this.dashboardCategoryDao.queryDashboardCategoryList(dashboardCategoryModel);
    }

    public DashboardCategoryModel updateDashboardCategoryById(DashboardCategoryModel dashboardCategoryModel){
        int result = this.dashboardCategoryDao.updateDashboardCategoryById(dashboardCategoryModel);
        if(result>0){
            return dashboardCategoryModel;
        }
        return null;
    }

    public  int deleteDashboardCategoryByIds(DashboardCategoryModel dashboardCategoryModel){
        return this.dashboardCategoryDao.deleteDashboardCategoryByIds(dashboardCategoryModel);
    }


    public DashboardCategoryDao getDashboardCategoryDao() {
        return dashboardCategoryDao;
    }

    @Autowired
    public void setDashboardCategoryDao(DashboardCategoryDao dashboardCategoryDao) {
        this.dashboardCategoryDao = dashboardCategoryDao;
    }
}
